# Use the official Node.js 18 image as the base image
FROM node:latest

# Set the working directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json (if available)
COPY package*.json ./

# set npm registry to cnpm
RUN npm config set registry https://registry.npmmirror.com

# Install pnpm globally
RUN npm install -g pnpm

# Install app dependencies using pnpm
RUN pnpm install

# Copy the rest of the application code
COPY . .

# Build the application using pnpm
RUN pnpm run build

# Expose the port the app runs on
EXPOSE 3000

# Start the application
CMD ["pnpm", "start"]